<?php
Modulator()->registerDataType('GoogleMapsLocation', CN_DOCUMENT_ROOT.'modules/gmaps/GoogleMapsLocation.php');


//define('GMAP_API_KEY', cn_get_option('gmap_api_key'));
define('GMAP_API_KEY', 'ABQIAAAAS0NP4UB5RR1KLMlGV7wPGhR4xFOApMXwhED3TSFvBjGZzrtYwhS_wFqztFZHAmq3icuO9JOkuDI21g');

function gmapDistanceQuery($original, $params) {
	if(!$original) $original = array();
	$data = $params['data'];
	$type = $params['type'];
	$lat = $data['latitude'];
	$lng = $data['longitude'];
	$distance = $data['distance'];
	if($lat && $lng && $distance) {
		/** Distance in miles, sorry euroweenies */
		$original[] = "(3956*2*ASIN(SQRT(POWER(SIN(('$lat' - `l".$type."_latitude`)*pi()/180/2),2) + COS('$lat'*pi()/180)*COS(`l".$type."_latitude`*pi()/180)*POWER(SIN(('$lng' - `l".$type."_longitude`)*pi()/180/2), 2))) <= '$distance')";

	}
	return $original;
}



?>